#include "row.h"

void Row::addData(const std::string &colName, const std::string &data){
	mapData.insert(std::pair<std::string,std::string>(colName, data));
}
void Row::printMapData(){
	 // showing contents:

//	  std::cout << "--------------------------------" <<"\n map data contains:\n" << std::endl;
	  for ( std::map<std::string,std::string>::iterator it=mapData.begin() ; it != mapData.end(); it++ ){
		  std::cout << (*it).first << " => " << (*it).second << " ; " <<std::endl;
	  }
}

bool Row::checkData(const std::string &colName, const std::string &value, char &con){
//	std::cout << "\nlooking for: "<< colName << " => " << value << " ; " <<std::endl;
	 for ( std::map<std::string,std::string>::iterator it=mapData.begin() ; it != mapData.end(); it++ ){
//		  std::cout << (*it).first << " => " << (*it).second << " ; " <<std::endl;
		  if( it->first == colName ){
			  if( con == '='){
				  if( it->second == value ) return true;
			  }else if( con =='>'){
				  if( it->second > value ) return true;
			  }
		  }
	 }
	 return false;
}

std::string Row::getData(std::string colName){
	  for ( std::map<std::string,std::string>::iterator it=mapData.begin() ; it != mapData.end(); it++ ){
//		  std::cout << (*it).first << " => " << (*it).second << " ; " <<std::endl;
		  if( it->first == colName ){
			  return it->second;
		  }
	  }
	  return "";
}
